package com.michir.project.tests.jms;

import java.io.Serializable;
import java.util.Calendar;
import java.util.Date;

public class Person implements Serializable {

	private static final long serialVersionUID = -5232051463485392252L;

	private String name;
	
	private Date birthDate;
	
	private final Sex sex;

	private Boolean readState = Boolean.FALSE;
	
	public Person(Sex sex) {
		this.sex = sex;
	}
	
	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the birthDate
	 */
	public Date getBirthDate() {
		return birthDate;
	}

	/**
	 * @param birthDate the birthDate to set
	 */
	public void setBirthDate(Date birthDate) {
		this.birthDate = birthDate;
	}
	

	/**
	 * @return the sex
	 */
	public Sex getSex() {
		return sex;
	}

	public Integer getAge() {
		Calendar instance = Calendar.getInstance();
		instance.setTime(birthDate);
		return Calendar.getInstance().get(Calendar.YEAR) - instance.get(Calendar.YEAR);
	}
	
	@Override
	public String toString() {
		return super.toString()+", name: "+name+", sex: "+sex+", age: "+getAge();
	}
	
	/**
	 * @return the readState
	 */
	public Boolean getReadState() {
		return readState;
	}

	/**
	 * @param readState the readState to set
	 */
	public void setReadState(Boolean readState) {
		this.readState = readState;
	}

	public static enum Sex {
		MAN,
		WORMAN;
	}
}
